﻿Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Printing
Imports System.Windows.Forms

Namespace System.Workflow.ComponentModel.Design
    Public NotInheritable Class WorkflowPageSetupDialog
        Inherits Form
        ' Methods
        Public Sub New(ByVal serviceProvider As IServiceProvider)
            If (serviceProvider Is Nothing) Then
                Throw New ArgumentNullException("serviceProvider")
            End If
            Me.serviceProvider = serviceProvider
            Dim service As WorkflowView = [TryCast](Me.serviceProvider.GetService(GetType(WorkflowView)),WorkflowView)
            If (service Is Nothing) Then
                Throw New InvalidOperationException(SR.GetString("General_MissingService", New Object() { GetType(WorkflowView).FullName }))
            End If
            If Not TypeOf service.PrintDocument Is WorkflowPrintDocument Then
                Throw New InvalidOperationException(DR.GetString("WorkflowPrintDocumentNotFound", New Object() { GetType(WorkflowPrintDocument).Name }))
            End If
            Try 
                Cursor.Current = Cursors.WaitCursor
                Me.InitializeComponent
                Me.printDocument = [TryCast](service.PrintDocument,WorkflowPrintDocument)
                Me.adjustToScaleInput.Value = Me.printDocument.PageSetupData.ScaleFactor
                Me.fitToPagesWideInput.Value = Me.printDocument.PageSetupData.PagesWide
                Me.fitToPagesTallInput.Value = Me.printDocument.PageSetupData.PagesTall
                If Me.printDocument.PageSetupData.AdjustToScaleFactor Then
                    Me.adjustToRadioButton.Checked = True
                Else
                    Me.fitToRadioButton.Checked = True
                End If
                If Me.printDocument.PageSetupData.Landscape Then
                    Me.landscapeRadioButton.Checked = True
                Else
                    Me.portraitRadioButton.Checked = True
                End If
                Me.SetMarginsToUI(Me.printDocument.PageSetupData.Margins)
                Me.CenterHorizontallyCheckBox.Checked = Me.printDocument.PageSetupData.CenterHorizontally
                Me.CenterVerticallyCheckBox.Checked = Me.printDocument.PageSetupData.CenterVertically
                Me.InitializePaperInformation
                Me.headerFooterNone = DR.GetString("HeaderFooterStringNone", New Object(0  - 1) {})
                Me.headerFooterCustom = DR.GetString("HeaderFooterStringCustom", New Object(0  - 1) {})
                Me.headerFooterTemplates = New String() { DR.GetString("HeaderFooterFormat1", New Object(0  - 1) {}), DR.GetString("HeaderFooterFormat2", New Object(0  - 1) {}), DR.GetString("HeaderFooterFormat3", New Object(0  - 1) {}), DR.GetString("HeaderFooterFormat4", New Object(0  - 1) {}), DR.GetString("HeaderFooterFormat5", New Object(0  - 1) {}), DR.GetString("HeaderFooterFormat6", New Object(0  - 1) {}), DR.GetString("HeaderFooterFormat7", New Object(0  - 1) {}), DR.GetString("HeaderFooterFormat8", New Object(0  - 1) {}), DR.GetString("HeaderFooterFormat9", New Object(0  - 1) {}) }
                Me.headerTextComboBox.Items.Add(Me.headerFooterNone)
                Me.headerTextComboBox.Items.AddRange(Me.headerFooterTemplates)
                Me.headerTextComboBox.Items.Add(Me.headerFooterCustom)
                Me.headerTextComboBox.SelectedIndex = 0
                Dim headerTemplate As String = Me.printDocument.PageSetupData.HeaderTemplate
                Me.headerCustom = Me.printDocument.PageSetupData.HeaderCustom
                If (headerTemplate.Length = 0) Then
                    Me.headerTextComboBox.SelectedIndex = 0
                Else
                    Dim index As Integer = Me.headerTextComboBox.Items.IndexOf(headerTemplate)
                    If ((-1 = index) OrElse Me.headerCustom) Then
                        Me.headerTextComboBox.SelectedIndex = Me.headerTextComboBox.Items.IndexOf(Me.headerFooterCustom)
                        Me.customHeaderText.Text = headerTemplate
                    Else
                        Me.headerTextComboBox.SelectedIndex = index
                    End If
                End If
                Me.headerAlignmentComboBox.Items.AddRange(New Object() { HorizontalAlignment.Left, HorizontalAlignment.Center, HorizontalAlignment.Right })
                If (Me.headerAlignmentComboBox.Items.IndexOf(Me.printDocument.PageSetupData.HeaderAlignment) <> -1) Then
                    Me.headerAlignmentComboBox.SelectedItem = Me.printDocument.PageSetupData.HeaderAlignment
                Else
                    Me.headerAlignmentComboBox.SelectedItem = HorizontalAlignment.Center
                End If
                Me.headerMarginInput.Value = Me.PrinterUnitToUIUnit(Me.printDocument.PageSetupData.HeaderMargin)
                Me.footerTextComboBox.Items.Add(Me.headerFooterNone)
                Me.footerTextComboBox.SelectedIndex = 0
                Me.footerTextComboBox.Items.AddRange(Me.headerFooterTemplates)
                Me.footerTextComboBox.Items.Add(Me.headerFooterCustom)
                Dim footerTemplate As String = Me.printDocument.PageSetupData.FooterTemplate
                Me.footerCustom = Me.printDocument.PageSetupData.FooterCustom
                If (footerTemplate.Length = 0) Then
                    Me.footerTextComboBox.SelectedIndex = 0
                Else
                    Dim num2 As Integer = Me.footerTextComboBox.Items.IndexOf(footerTemplate)
                    If ((-1 = num2) OrElse Me.footerCustom) Then
                        Me.footerTextComboBox.SelectedIndex = Me.footerTextComboBox.Items.IndexOf(Me.headerFooterCustom)
                        Me.customFooterText.Text = footerTemplate
                    Else
                        Me.footerTextComboBox.SelectedIndex = num2
                    End If
                End If
                Me.footerAlignmentComboBox.Items.AddRange(New Object() { HorizontalAlignment.Left, HorizontalAlignment.Center, HorizontalAlignment.Right })
                If (Me.footerAlignmentComboBox.Items.IndexOf(Me.printDocument.PageSetupData.FooterAlignment) <> -1) Then
                    Me.footerAlignmentComboBox.SelectedItem = Me.printDocument.PageSetupData.FooterAlignment
                Else
                    Me.footerAlignmentComboBox.SelectedItem = HorizontalAlignment.Center
                End If
                Me.footerMarginInput.Value = Me.PrinterUnitToUIUnit(Me.printDocument.PageSetupData.FooterMargin)
            Finally
                Cursor.Current = Cursors.Default
            End Try
        End Sub

        Private Sub adjustToInput_ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
            Me.adjustToRadioButton.Checked = True
        End Sub

        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            If (disposing AndAlso (Not Me.components Is Nothing)) Then
                Me.components.Dispose
            End If
            MyBase.Dispose(disposing)
        End Sub

        Private Sub fitToInputs_ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
            Me.fitToRadioButton.Checked = True
        End Sub

        Private Sub footerMarginInput_Validating(ByVal sender As Object, ByVal e As CancelEventArgs)
        End Sub

        Private Sub footerTextComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
            Me.footerCustom = Me.footerTextComboBox.Text.Equals(Me.headerFooterCustom)
            Me.customFooterText.Enabled = Me.footerCustom
            If Not Me.footerCustom Then
                Me.customFooterText.Text = Me.footerTextComboBox.Text
            End If
        End Sub

        Private Sub GetHelp()
            DesignerHelpers.ShowHelpFromKeyword(Me.serviceProvider, (GetType(WorkflowPageSetupDialog).FullName & ".UI"))
        End Sub

        Private Function GetMarginsFromUI() As Margins
            Return New Margins(Me.UIUnitToPrinterUnit(Me.marginsLeftInput.Value), Me.UIUnitToPrinterUnit(Me.marginsRightInput.Value), Me.UIUnitToPrinterUnit(Me.marginsTopInput.Value), Me.UIUnitToPrinterUnit(Me.marginsBottomInput.Value))
        End Function

        Private Sub headerMarginInput_Validating(ByVal sender As Object, ByVal e As CancelEventArgs)
        End Sub

        Private Sub headerTextComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
            Me.headerCustom = Me.headerTextComboBox.Text.Equals(Me.headerFooterCustom)
            Me.customHeaderText.Enabled = Me.headerCustom
            If Not Me.headerCustom Then
                Me.customHeaderText.Text = Me.headerTextComboBox.Text
            End If
        End Sub

        Private Sub InitializeComponent()
            Dim manager As New ComponentResourceManager(GetType(WorkflowPageSetupDialog))
            Me.tabs = New TabControl
            Me.pageSettingsTab = New TabPage
            Me.centerGroup = New GroupBox
            Me.centerTableLayoutPanel = New TableLayoutPanel
            Me.CenterVerticallyCheckBox = New CheckBox
            Me.CenterHorizontallyCheckBox = New CheckBox
            Me.marginsGroup = New GroupBox
            Me.marginsTableLayoutPanel = New TableLayoutPanel
            Me.marginsRightInput = New NumericUpDown
            Me.marginsBottomInput = New NumericUpDown
            Me.marginsTopLabel = New Label
            Me.marginsLeftLabel = New Label
            Me.marginsRightLabel = New Label
            Me.marginsBottomLabel = New Label
            Me.marginsTopInput = New NumericUpDown
            Me.marginsLeftInput = New NumericUpDown
            Me.scalingGroup = New GroupBox
            Me.scalingTableLayoutPanel = New TableLayoutPanel
            Me.fitToTallLabel = New Label
            Me.scalingOfSizeLabel = New Label
            Me.fitToWideLabel = New Label
            Me.adjustToRadioButton = New RadioButton
            Me.fitToPagesTallInput = New NumericUpDown
            Me.fitToPagesWideInput = New NumericUpDown
            Me.adjustToScaleInput = New NumericUpDown
            Me.fitToRadioButton = New RadioButton
            Me.orientationGroup = New GroupBox
            Me.orientationTableLayoutPanel = New TableLayoutPanel
            Me.landscapeRadioButton = New RadioButton
            Me.landscapePicture = New PictureBox
            Me.portraitRadioButton = New RadioButton
            Me.portraitPicture = New PictureBox
            Me.paperSettingsGroup = New GroupBox
            Me.paperTableLayoutPanel = New TableLayoutPanel
            Me.paperSourceComboBox = New ComboBox
            Me.paperSizeComboBox = New ComboBox
            Me.paperSizeLabel = New Label
            Me.paperSourceLabel = New Label
            Me.headerFooterTab = New TabPage
            Me.footerGroup = New GroupBox
            Me.footerTableLayoutPanel = New TableLayoutPanel
            Me.footerTextLabel = New Label
            Me.footerAlignmentLabel = New Label
            Me.footerMarginUnitsLabel = New Label
            Me.footerMarginLabel = New Label
            Me.footerMarginInput = New NumericUpDown
            Me.footerTextComboBox = New ComboBox
            Me.footerAlignmentComboBox = New ComboBox
            Me.customFooterText = New TextBox
            Me.customFooterLabel = New Label
            Me.headerGroup = New GroupBox
            Me.headerTableLayoutPanel = New TableLayoutPanel
            Me.headerTextLabel = New Label
            Me.headerAlignmentLabel = New Label
            Me.headerMarginUnitsLabel = New Label
            Me.headerMarginLabel = New Label
            Me.headerMarginInput = New NumericUpDown
            Me.headerTextComboBox = New ComboBox
            Me.headerAlignmentComboBox = New ComboBox
            Me.customHeaderText = New TextBox
            Me.customHeaderLabel = New Label
            Me.OKButton = New Button
            Me.cancelButton = New Button
            Me.printerButton = New Button
            Me.okCancelTableLayoutPanel = New TableLayoutPanel
            Me.tabs.SuspendLayout
            Me.pageSettingsTab.SuspendLayout
            Me.centerGroup.SuspendLayout
            Me.centerTableLayoutPanel.SuspendLayout
            Me.marginsGroup.SuspendLayout
            Me.marginsTableLayoutPanel.SuspendLayout
            Me.marginsRightInput.BeginInit
            Me.marginsBottomInput.BeginInit
            Me.marginsTopInput.BeginInit
            Me.marginsLeftInput.BeginInit
            Me.scalingGroup.SuspendLayout
            Me.scalingTableLayoutPanel.SuspendLayout
            Me.fitToPagesTallInput.BeginInit
            Me.fitToPagesWideInput.BeginInit
            Me.adjustToScaleInput.BeginInit
            Me.orientationGroup.SuspendLayout
            Me.orientationTableLayoutPanel.SuspendLayout
            DirectCast(Me.landscapePicture, ISupportInitialize).BeginInit
            DirectCast(Me.portraitPicture, ISupportInitialize).BeginInit
            Me.paperSettingsGroup.SuspendLayout
            Me.paperTableLayoutPanel.SuspendLayout
            Me.headerFooterTab.SuspendLayout
            Me.footerGroup.SuspendLayout
            Me.footerTableLayoutPanel.SuspendLayout
            Me.footerMarginInput.BeginInit
            Me.headerGroup.SuspendLayout
            Me.headerTableLayoutPanel.SuspendLayout
            Me.headerMarginInput.BeginInit
            Me.okCancelTableLayoutPanel.SuspendLayout
            MyBase.SuspendLayout
            manager.ApplyResources(Me.tabs, "tabs")
            Me.tabs.Controls.Add(Me.pageSettingsTab)
            Me.tabs.Controls.Add(Me.headerFooterTab)
            Me.tabs.Name = "tabs"
            Me.tabs.SelectedIndex = 0
            Me.pageSettingsTab.Controls.Add(Me.centerGroup)
            Me.pageSettingsTab.Controls.Add(Me.marginsGroup)
            Me.pageSettingsTab.Controls.Add(Me.scalingGroup)
            Me.pageSettingsTab.Controls.Add(Me.orientationGroup)
            Me.pageSettingsTab.Controls.Add(Me.paperSettingsGroup)
            manager.ApplyResources(Me.pageSettingsTab, "pageSettingsTab")
            Me.pageSettingsTab.Name = "pageSettingsTab"
            manager.ApplyResources(Me.centerGroup, "centerGroup")
            Me.centerGroup.Controls.Add(Me.centerTableLayoutPanel)
            Me.centerGroup.Name = "centerGroup"
            Me.centerGroup.TabStop = False
            manager.ApplyResources(Me.centerTableLayoutPanel, "centerTableLayoutPanel")
            Me.centerTableLayoutPanel.Controls.Add(Me.CenterVerticallyCheckBox, 1, 0)
            Me.centerTableLayoutPanel.Controls.Add(Me.CenterHorizontallyCheckBox, 0, 0)
            Me.centerTableLayoutPanel.Name = "centerTableLayoutPanel"
            manager.ApplyResources(Me.CenterVerticallyCheckBox, "CenterVerticallyCheckBox")
            Me.CenterVerticallyCheckBox.Name = "CenterVerticallyCheckBox"
            manager.ApplyResources(Me.CenterHorizontallyCheckBox, "CenterHorizontallyCheckBox")
            Me.CenterHorizontallyCheckBox.Name = "CenterHorizontallyCheckBox"
            manager.ApplyResources(Me.marginsGroup, "marginsGroup")
            Me.marginsGroup.Controls.Add(Me.marginsTableLayoutPanel)
            Me.marginsGroup.Name = "marginsGroup"
            Me.marginsGroup.TabStop = False
            manager.ApplyResources(Me.marginsTableLayoutPanel, "marginsTableLayoutPanel")
            Me.marginsTableLayoutPanel.Controls.Add(Me.marginsRightInput, 3, 1)
            Me.marginsTableLayoutPanel.Controls.Add(Me.marginsBottomInput, 3, 0)
            Me.marginsTableLayoutPanel.Controls.Add(Me.marginsTopLabel, 0, 0)
            Me.marginsTableLayoutPanel.Controls.Add(Me.marginsLeftLabel, 0, 1)
            Me.marginsTableLayoutPanel.Controls.Add(Me.marginsRightLabel, 2, 1)
            Me.marginsTableLayoutPanel.Controls.Add(Me.marginsBottomLabel, 2, 0)
            Me.marginsTableLayoutPanel.Controls.Add(Me.marginsTopInput, 1, 0)
            Me.marginsTableLayoutPanel.Controls.Add(Me.marginsLeftInput, 1, 1)
            Me.marginsTableLayoutPanel.Name = "marginsTableLayoutPanel"
            manager.ApplyResources(Me.marginsRightInput, "marginsRightInput")
            Me.marginsRightInput.DecimalPlaces = 2
            Dim bits As Integer() = New Integer(4  - 1) {}
            bits(0) = 1
            bits(3) = &H20000
            Me.marginsRightInput.Increment = New Decimal(bits)
            Me.marginsRightInput.Name = "marginsRightInput"
            Dim numArray2 As Integer() = New Integer(4  - 1) {}
            numArray2(0) = 100
            numArray2(3) = &H20000
            Me.marginsRightInput.Value = New Decimal(numArray2)
            AddHandler Me.marginsRightInput.Validating, New CancelEventHandler(AddressOf Me.Margins_Validating)
            manager.ApplyResources(Me.marginsBottomInput, "marginsBottomInput")
            Me.marginsBottomInput.DecimalPlaces = 2
            Dim numArray3 As Integer() = New Integer(4  - 1) {}
            numArray3(0) = 1
            numArray3(3) = &H20000
            Me.marginsBottomInput.Increment = New Decimal(numArray3)
            Me.marginsBottomInput.Name = "marginsBottomInput"
            Dim numArray4 As Integer() = New Integer(4  - 1) {}
            numArray4(0) = 100
            numArray4(3) = &H20000
            Me.marginsBottomInput.Value = New Decimal(numArray4)
            AddHandler Me.marginsBottomInput.Validating, New CancelEventHandler(AddressOf Me.Margins_Validating)
            manager.ApplyResources(Me.marginsTopLabel, "marginsTopLabel")
            Me.marginsTopLabel.Name = "marginsTopLabel"
            manager.ApplyResources(Me.marginsLeftLabel, "marginsLeftLabel")
            Me.marginsLeftLabel.Name = "marginsLeftLabel"
            manager.ApplyResources(Me.marginsRightLabel, "marginsRightLabel")
            Me.marginsRightLabel.Name = "marginsRightLabel"
            manager.ApplyResources(Me.marginsBottomLabel, "marginsBottomLabel")
            Me.marginsBottomLabel.Name = "marginsBottomLabel"
            manager.ApplyResources(Me.marginsTopInput, "marginsTopInput")
            Me.marginsTopInput.DecimalPlaces = 2
            Dim numArray5 As Integer() = New Integer(4  - 1) {}
            numArray5(0) = 1
            numArray5(3) = &H20000
            Me.marginsTopInput.Increment = New Decimal(numArray5)
            Me.marginsTopInput.Name = "marginsTopInput"
            Dim numArray6 As Integer() = New Integer(4  - 1) {}
            numArray6(0) = 100
            numArray6(3) = &H20000
            Me.marginsTopInput.Value = New Decimal(numArray6)
            AddHandler Me.marginsTopInput.Validating, New CancelEventHandler(AddressOf Me.Margins_Validating)
            manager.ApplyResources(Me.marginsLeftInput, "marginsLeftInput")
            Me.marginsLeftInput.DecimalPlaces = 2
            Dim numArray7 As Integer() = New Integer(4  - 1) {}
            numArray7(0) = 1
            numArray7(3) = &H20000
            Me.marginsLeftInput.Increment = New Decimal(numArray7)
            Me.marginsLeftInput.Name = "marginsLeftInput"
            Dim numArray8 As Integer() = New Integer(4  - 1) {}
            numArray8(0) = 100
            numArray8(3) = &H20000
            Me.marginsLeftInput.Value = New Decimal(numArray8)
            AddHandler Me.marginsLeftInput.Validating, New CancelEventHandler(AddressOf Me.Margins_Validating)
            manager.ApplyResources(Me.scalingGroup, "scalingGroup")
            Me.scalingGroup.Controls.Add(Me.scalingTableLayoutPanel)
            Me.scalingGroup.Name = "scalingGroup"
            Me.scalingGroup.TabStop = False
            manager.ApplyResources(Me.scalingTableLayoutPanel, "scalingTableLayoutPanel")
            Me.scalingTableLayoutPanel.Controls.Add(Me.fitToTallLabel, 2, 2)
            Me.scalingTableLayoutPanel.Controls.Add(Me.scalingOfSizeLabel, 2, 0)
            Me.scalingTableLayoutPanel.Controls.Add(Me.fitToWideLabel, 2, 1)
            Me.scalingTableLayoutPanel.Controls.Add(Me.adjustToRadioButton, 0, 0)
            Me.scalingTableLayoutPanel.Controls.Add(Me.fitToPagesTallInput, 1, 2)
            Me.scalingTableLayoutPanel.Controls.Add(Me.fitToPagesWideInput, 1, 1)
            Me.scalingTableLayoutPanel.Controls.Add(Me.adjustToScaleInput, 1, 0)
            Me.scalingTableLayoutPanel.Controls.Add(Me.fitToRadioButton, 0, 1)
            Me.scalingTableLayoutPanel.Name = "scalingTableLayoutPanel"
            manager.ApplyResources(Me.fitToTallLabel, "fitToTallLabel")
            Me.fitToTallLabel.Name = "fitToTallLabel"
            manager.ApplyResources(Me.scalingOfSizeLabel, "scalingOfSizeLabel")
            Me.scalingOfSizeLabel.Name = "scalingOfSizeLabel"
            manager.ApplyResources(Me.fitToWideLabel, "fitToWideLabel")
            Me.fitToWideLabel.Name = "fitToWideLabel"
            manager.ApplyResources(Me.adjustToRadioButton, "adjustToRadioButton")
            Me.adjustToRadioButton.Name = "adjustToRadioButton"
            manager.ApplyResources(Me.fitToPagesTallInput, "fitToPagesTallInput")
            Dim numArray9 As Integer() = New Integer(4  - 1) {}
            numArray9(0) = 20
            Me.fitToPagesTallInput.Maximum = New Decimal(numArray9)
            Dim numArray10 As Integer() = New Integer(4  - 1) {}
            numArray10(0) = 1
            Me.fitToPagesTallInput.Minimum = New Decimal(numArray10)
            Me.fitToPagesTallInput.Name = "fitToPagesTallInput"
            Dim numArray11 As Integer() = New Integer(4  - 1) {}
            numArray11(0) = 1
            Me.fitToPagesTallInput.Value = New Decimal(numArray11)
            AddHandler Me.fitToPagesTallInput.ValueChanged, New EventHandler(AddressOf Me.fitToInputs_ValueChanged)
            manager.ApplyResources(Me.fitToPagesWideInput, "fitToPagesWideInput")
            Dim numArray12 As Integer() = New Integer(4  - 1) {}
            numArray12(0) = 20
            Me.fitToPagesWideInput.Maximum = New Decimal(numArray12)
            Dim numArray13 As Integer() = New Integer(4  - 1) {}
            numArray13(0) = 1
            Me.fitToPagesWideInput.Minimum = New Decimal(numArray13)
            Me.fitToPagesWideInput.Name = "fitToPagesWideInput"
            Dim numArray14 As Integer() = New Integer(4  - 1) {}
            numArray14(0) = 1
            Me.fitToPagesWideInput.Value = New Decimal(numArray14)
            AddHandler Me.fitToPagesWideInput.ValueChanged, New EventHandler(AddressOf Me.fitToInputs_ValueChanged)
            manager.ApplyResources(Me.adjustToScaleInput, "adjustToScaleInput")
            Dim numArray15 As Integer() = New Integer(4  - 1) {}
            numArray15(0) = 400
            Me.adjustToScaleInput.Maximum = New Decimal(numArray15)
            Dim numArray16 As Integer() = New Integer(4  - 1) {}
            numArray16(0) = 10
            Me.adjustToScaleInput.Minimum = New Decimal(numArray16)
            Me.adjustToScaleInput.Name = "adjustToScaleInput"
            Dim numArray17 As Integer() = New Integer(4  - 1) {}
            numArray17(0) = 100
            Me.adjustToScaleInput.Value = New Decimal(numArray17)
            AddHandler Me.adjustToScaleInput.ValueChanged, New EventHandler(AddressOf Me.adjustToInput_ValueChanged)
            manager.ApplyResources(Me.fitToRadioButton, "fitToRadioButton")
            Me.fitToRadioButton.Name = "fitToRadioButton"
            manager.ApplyResources(Me.orientationGroup, "orientationGroup")
            Me.orientationGroup.Controls.Add(Me.orientationTableLayoutPanel)
            Me.orientationGroup.Name = "orientationGroup"
            Me.orientationGroup.TabStop = False
            manager.ApplyResources(Me.orientationTableLayoutPanel, "orientationTableLayoutPanel")
            Me.orientationTableLayoutPanel.Controls.Add(Me.landscapeRadioButton, 3, 0)
            Me.orientationTableLayoutPanel.Controls.Add(Me.landscapePicture, 2, 0)
            Me.orientationTableLayoutPanel.Controls.Add(Me.portraitRadioButton, 1, 0)
            Me.orientationTableLayoutPanel.Controls.Add(Me.portraitPicture, 0, 0)
            Me.orientationTableLayoutPanel.Name = "orientationTableLayoutPanel"
            manager.ApplyResources(Me.landscapeRadioButton, "landscapeRadioButton")
            Me.landscapeRadioButton.Name = "landscapeRadioButton"
            AddHandler Me.landscapeRadioButton.CheckedChanged, New EventHandler(AddressOf Me.landscapeRadioButton_CheckedChanged)
            manager.ApplyResources(Me.landscapePicture, "landscapePicture")
            Me.landscapePicture.Name = "landscapePicture"
            Me.landscapePicture.TabStop = False
            manager.ApplyResources(Me.portraitRadioButton, "portraitRadioButton")
            Me.portraitRadioButton.Name = "portraitRadioButton"
            AddHandler Me.portraitRadioButton.CheckedChanged, New EventHandler(AddressOf Me.portraitRadioButton_CheckedChanged)
            manager.ApplyResources(Me.portraitPicture, "portraitPicture")
            Me.portraitPicture.Name = "portraitPicture"
            Me.portraitPicture.TabStop = False
            manager.ApplyResources(Me.paperSettingsGroup, "paperSettingsGroup")
            Me.paperSettingsGroup.Controls.Add(Me.paperTableLayoutPanel)
            Me.paperSettingsGroup.Name = "paperSettingsGroup"
            Me.paperSettingsGroup.TabStop = False
            manager.ApplyResources(Me.paperTableLayoutPanel, "paperTableLayoutPanel")
            Me.paperTableLayoutPanel.Controls.Add(Me.paperSourceComboBox, 1, 1)
            Me.paperTableLayoutPanel.Controls.Add(Me.paperSizeComboBox, 1, 0)
            Me.paperTableLayoutPanel.Controls.Add(Me.paperSizeLabel, 0, 0)
            Me.paperTableLayoutPanel.Controls.Add(Me.paperSourceLabel, 0, 1)
            Me.paperTableLayoutPanel.Name = "paperTableLayoutPanel"
            manager.ApplyResources(Me.paperSourceComboBox, "paperSourceComboBox")
            Me.paperSourceComboBox.DropDownStyle = ComboBoxStyle.DropDownList
            Me.paperSourceComboBox.FormattingEnabled = True
            Me.paperSourceComboBox.Name = "paperSourceComboBox"
            manager.ApplyResources(Me.paperSizeComboBox, "paperSizeComboBox")
            Me.paperSizeComboBox.DropDownStyle = ComboBoxStyle.DropDownList
            Me.paperSizeComboBox.FormattingEnabled = True
            Me.paperSizeComboBox.Name = "paperSizeComboBox"
            AddHandler Me.paperSizeComboBox.SelectedIndexChanged, New EventHandler(AddressOf Me.paperSizeComboBox_SelectedIndexChanged)
            manager.ApplyResources(Me.paperSizeLabel, "paperSizeLabel")
            Me.paperSizeLabel.Name = "paperSizeLabel"
            manager.ApplyResources(Me.paperSourceLabel, "paperSourceLabel")
            Me.paperSourceLabel.Name = "paperSourceLabel"
            Me.headerFooterTab.Controls.Add(Me.footerGroup)
            Me.headerFooterTab.Controls.Add(Me.headerGroup)
            manager.ApplyResources(Me.headerFooterTab, "headerFooterTab")
            Me.headerFooterTab.Name = "headerFooterTab"
            manager.ApplyResources(Me.footerGroup, "footerGroup")
            Me.footerGroup.Controls.Add(Me.footerTableLayoutPanel)
            Me.footerGroup.Controls.Add(Me.customFooterText)
            Me.footerGroup.Controls.Add(Me.customFooterLabel)
            Me.footerGroup.Name = "footerGroup"
            Me.footerGroup.TabStop = False
            manager.ApplyResources(Me.footerTableLayoutPanel, "footerTableLayoutPanel")
            Me.footerTableLayoutPanel.Controls.Add(Me.footerTextLabel, 0, 0)
            Me.footerTableLayoutPanel.Controls.Add(Me.footerAlignmentLabel, 0, 1)
            Me.footerTableLayoutPanel.Controls.Add(Me.footerMarginUnitsLabel, 2, 2)
            Me.footerTableLayoutPanel.Controls.Add(Me.footerMarginLabel, 0, 2)
            Me.footerTableLayoutPanel.Controls.Add(Me.footerMarginInput, 1, 2)
            Me.footerTableLayoutPanel.Controls.Add(Me.footerTextComboBox, 1, 0)
            Me.footerTableLayoutPanel.Controls.Add(Me.footerAlignmentComboBox, 1, 1)
            Me.footerTableLayoutPanel.Name = "footerTableLayoutPanel"
            manager.ApplyResources(Me.footerTextLabel, "footerTextLabel")
            Me.footerTextLabel.Name = "footerTextLabel"
            manager.ApplyResources(Me.footerAlignmentLabel, "footerAlignmentLabel")
            Me.footerAlignmentLabel.Name = "footerAlignmentLabel"
            manager.ApplyResources(Me.footerMarginUnitsLabel, "footerMarginUnitsLabel")
            Me.footerMarginUnitsLabel.Name = "footerMarginUnitsLabel"
            manager.ApplyResources(Me.footerMarginLabel, "footerMarginLabel")
            Me.footerMarginLabel.Name = "footerMarginLabel"
            manager.ApplyResources(Me.footerMarginInput, "footerMarginInput")
            Me.footerMarginInput.DecimalPlaces = 2
            Dim numArray18 As Integer() = New Integer(4  - 1) {}
            numArray18(0) = 1
            numArray18(3) = &H20000
            Me.footerMarginInput.Increment = New Decimal(numArray18)
            Me.footerMarginInput.Name = "footerMarginInput"
            Dim numArray19 As Integer() = New Integer(4  - 1) {}
            numArray19(0) = 1
            Me.footerMarginInput.Value = New Decimal(numArray19)
            AddHandler Me.footerMarginInput.Validating, New CancelEventHandler(AddressOf Me.footerMarginInput_Validating)
            manager.ApplyResources(Me.footerTextComboBox, "footerTextComboBox")
            Me.footerTableLayoutPanel.SetColumnSpan(Me.footerTextComboBox, 2)
            Me.footerTextComboBox.DropDownStyle = ComboBoxStyle.DropDownList
            Me.footerTextComboBox.FormattingEnabled = True
            Me.footerTextComboBox.Name = "footerTextComboBox"
            AddHandler Me.footerTextComboBox.SelectedIndexChanged, New EventHandler(AddressOf Me.footerTextComboBox_SelectedIndexChanged)
            manager.ApplyResources(Me.footerAlignmentComboBox, "footerAlignmentComboBox")
            Me.footerTableLayoutPanel.SetColumnSpan(Me.footerAlignmentComboBox, 2)
            Me.footerAlignmentComboBox.DropDownStyle = ComboBoxStyle.DropDownList
            Me.footerAlignmentComboBox.FormattingEnabled = True
            Me.footerAlignmentComboBox.Name = "footerAlignmentComboBox"
            manager.ApplyResources(Me.customFooterText, "customFooterText")
            Me.customFooterText.Name = "customFooterText"
            manager.ApplyResources(Me.customFooterLabel, "customFooterLabel")
            Me.customFooterLabel.Name = "customFooterLabel"
            manager.ApplyResources(Me.headerGroup, "headerGroup")
            Me.headerGroup.Controls.Add(Me.headerTableLayoutPanel)
            Me.headerGroup.Controls.Add(Me.customHeaderText)
            Me.headerGroup.Controls.Add(Me.customHeaderLabel)
            Me.headerGroup.Name = "headerGroup"
            Me.headerGroup.TabStop = False
            manager.ApplyResources(Me.headerTableLayoutPanel, "headerTableLayoutPanel")
            Me.headerTableLayoutPanel.Controls.Add(Me.headerTextLabel, 0, 0)
            Me.headerTableLayoutPanel.Controls.Add(Me.headerAlignmentLabel, 0, 1)
            Me.headerTableLayoutPanel.Controls.Add(Me.headerMarginUnitsLabel, 2, 2)
            Me.headerTableLayoutPanel.Controls.Add(Me.headerMarginLabel, 0, 2)
            Me.headerTableLayoutPanel.Controls.Add(Me.headerMarginInput, 1, 2)
            Me.headerTableLayoutPanel.Controls.Add(Me.headerTextComboBox, 1, 0)
            Me.headerTableLayoutPanel.Controls.Add(Me.headerAlignmentComboBox, 1, 1)
            Me.headerTableLayoutPanel.Name = "headerTableLayoutPanel"
            manager.ApplyResources(Me.headerTextLabel, "headerTextLabel")
            Me.headerTextLabel.Name = "headerTextLabel"
            manager.ApplyResources(Me.headerAlignmentLabel, "headerAlignmentLabel")
            Me.headerAlignmentLabel.Cursor = Cursors.Arrow
            Me.headerAlignmentLabel.Name = "headerAlignmentLabel"
            manager.ApplyResources(Me.headerMarginUnitsLabel, "headerMarginUnitsLabel")
            Me.headerMarginUnitsLabel.Name = "headerMarginUnitsLabel"
            manager.ApplyResources(Me.headerMarginLabel, "headerMarginLabel")
            Me.headerMarginLabel.Name = "headerMarginLabel"
            manager.ApplyResources(Me.headerMarginInput, "headerMarginInput")
            Me.headerMarginInput.DecimalPlaces = 2
            Dim numArray20 As Integer() = New Integer(4  - 1) {}
            numArray20(0) = 1
            numArray20(3) = &H20000
            Me.headerMarginInput.Increment = New Decimal(numArray20)
            Me.headerMarginInput.Name = "headerMarginInput"
            Dim numArray21 As Integer() = New Integer(4  - 1) {}
            numArray21(0) = 1
            Me.headerMarginInput.Value = New Decimal(numArray21)
            AddHandler Me.headerMarginInput.Validating, New CancelEventHandler(AddressOf Me.headerMarginInput_Validating)
            manager.ApplyResources(Me.headerTextComboBox, "headerTextComboBox")
            Me.headerTableLayoutPanel.SetColumnSpan(Me.headerTextComboBox, 2)
            Me.headerTextComboBox.DropDownStyle = ComboBoxStyle.DropDownList
            Me.headerTextComboBox.FormattingEnabled = True
            Me.headerTextComboBox.Name = "headerTextComboBox"
            AddHandler Me.headerTextComboBox.SelectedIndexChanged, New EventHandler(AddressOf Me.headerTextComboBox_SelectedIndexChanged)
            manager.ApplyResources(Me.headerAlignmentComboBox, "headerAlignmentComboBox")
            Me.headerTableLayoutPanel.SetColumnSpan(Me.headerAlignmentComboBox, 2)
            Me.headerAlignmentComboBox.DropDownStyle = ComboBoxStyle.DropDownList
            Me.headerAlignmentComboBox.FormattingEnabled = True
            Me.headerAlignmentComboBox.Name = "headerAlignmentComboBox"
            manager.ApplyResources(Me.customHeaderText, "customHeaderText")
            Me.customHeaderText.Name = "customHeaderText"
            manager.ApplyResources(Me.customHeaderLabel, "customHeaderLabel")
            Me.customHeaderLabel.Name = "customHeaderLabel"
            manager.ApplyResources(Me.OKButton, "OKButton")
            Me.OKButton.DialogResult = DialogResult.OK
            Me.OKButton.Name = "OKButton"
            AddHandler Me.OKButton.Click, New EventHandler(AddressOf Me.OKButton_Click)
            manager.ApplyResources(Me.cancelButton, "cancelButton")
            Me.cancelButton.DialogResult = DialogResult.Cancel
            Me.cancelButton.Name = "cancelButton"
            manager.ApplyResources(Me.printerButton, "printerButton")
            Me.printerButton.Name = "printerButton"
            AddHandler Me.printerButton.Click, New EventHandler(AddressOf Me.printerButton_Click)
            manager.ApplyResources(Me.okCancelTableLayoutPanel, "okCancelTableLayoutPanel")
            Me.okCancelTableLayoutPanel.Controls.Add(Me.OKButton, 0, 0)
            Me.okCancelTableLayoutPanel.Controls.Add(Me.cancelButton, 1, 0)
            Me.okCancelTableLayoutPanel.Controls.Add(Me.printerButton, 2, 0)
            Me.okCancelTableLayoutPanel.Name = "okCancelTableLayoutPanel"
            MyBase.AcceptButton = Me.OKButton
            manager.ApplyResources(Me, "$this")
            MyBase.CancelButton = Me.cancelButton
            MyBase.Controls.Add(Me.okCancelTableLayoutPanel)
            MyBase.Controls.Add(Me.tabs)
            MyBase.FormBorderStyle = FormBorderStyle.FixedDialog
            MyBase.HelpButton = True
            MyBase.MaximizeBox = False
            MyBase.MinimizeBox = False
            MyBase.Name = "WorkflowPageSetupDialog"
            MyBase.ShowInTaskbar = False
            AddHandler MyBase.HelpButtonClicked, New CancelEventHandler(AddressOf Me.WorkflowPageSetupDialog_HelpButtonClicked)
            Me.tabs.ResumeLayout(False)
            Me.pageSettingsTab.ResumeLayout(False)
            Me.centerGroup.ResumeLayout(False)
            Me.centerTableLayoutPanel.ResumeLayout(False)
            Me.centerTableLayoutPanel.PerformLayout
            Me.marginsGroup.ResumeLayout(False)
            Me.marginsTableLayoutPanel.ResumeLayout(False)
            Me.marginsTableLayoutPanel.PerformLayout
            Me.marginsRightInput.EndInit
            Me.marginsBottomInput.EndInit
            Me.marginsTopInput.EndInit
            Me.marginsLeftInput.EndInit
            Me.scalingGroup.ResumeLayout(False)
            Me.scalingTableLayoutPanel.ResumeLayout(False)
            Me.scalingTableLayoutPanel.PerformLayout
            Me.fitToPagesTallInput.EndInit
            Me.fitToPagesWideInput.EndInit
            Me.adjustToScaleInput.EndInit
            Me.orientationGroup.ResumeLayout(False)
            Me.orientationTableLayoutPanel.ResumeLayout(False)
            Me.orientationTableLayoutPanel.PerformLayout
            DirectCast(Me.landscapePicture, ISupportInitialize).EndInit
            DirectCast(Me.portraitPicture, ISupportInitialize).EndInit
            Me.paperSettingsGroup.ResumeLayout(False)
            Me.paperTableLayoutPanel.ResumeLayout(False)
            Me.paperTableLayoutPanel.PerformLayout
            Me.headerFooterTab.ResumeLayout(False)
            Me.footerGroup.ResumeLayout(False)
            Me.footerGroup.PerformLayout
            Me.footerTableLayoutPanel.ResumeLayout(False)
            Me.footerTableLayoutPanel.PerformLayout
            Me.footerMarginInput.EndInit
            Me.headerGroup.ResumeLayout(False)
            Me.headerGroup.PerformLayout
            Me.headerTableLayoutPanel.ResumeLayout(False)
            Me.headerTableLayoutPanel.PerformLayout
            Me.headerMarginInput.EndInit
            Me.okCancelTableLayoutPanel.ResumeLayout(False)
            Me.okCancelTableLayoutPanel.PerformLayout
            MyBase.ResumeLayout(False)
            MyBase.PerformLayout
        End Sub

        Private Sub InitializePaperInformation()
            Dim paperSizes As PaperSizeCollection = Me.printDocument.PrinterSettings.PaperSizes
            Dim paperSources As PaperSourceCollection = Me.printDocument.PrinterSettings.PaperSources
            Me.paperSizeComboBox.Items.Clear
            Me.paperSizeComboBox.DisplayMember = "PaperName"
            Dim size As PaperSize
            For Each size In paperSizes
                If ((Not size.PaperName Is Nothing) AndAlso (size.PaperName.Length > 0)) Then
                    Me.paperSizeComboBox.Items.Add(size)
                    If (((Me.paperSizeComboBox.SelectedItem Is Nothing) AndAlso (Me.printDocument.DefaultPageSettings.PaperSize.Kind = size.Kind)) AndAlso ((Me.printDocument.DefaultPageSettings.PaperSize.Width = size.Width) AndAlso (Me.printDocument.DefaultPageSettings.PaperSize.Height = size.Height))) Then
                        Me.paperSizeComboBox.SelectedItem = size
                        Me.printDocument.DefaultPageSettings.PaperSize = size
                    End If
                End If
            Next
            If (Me.paperSizeComboBox.SelectedItem Is Nothing) Then
                Dim kind As PaperKind = Me.printDocument.DefaultPageSettings.PaperSize.Kind
                Me.printDocument.DefaultPageSettings = New PageSettings(Me.printDocument.PrinterSettings)
                Dim size2 As PaperSize
                For Each size2 In Me.paperSizeComboBox.Items
                    If (((Me.paperSizeComboBox.SelectedItem Is Nothing) AndAlso (kind = size2.Kind)) AndAlso ((Me.printDocument.DefaultPageSettings.PaperSize.Width = size2.Width) AndAlso (Me.printDocument.DefaultPageSettings.PaperSize.Height = size2.Height))) Then
                        Me.paperSizeComboBox.SelectedItem = size2
                        Me.printDocument.DefaultPageSettings.PaperSize = size2
                    End If
                Next
                If ((Me.paperSizeComboBox.SelectedItem Is Nothing) AndAlso (Me.paperSizeComboBox.Items.Count > 0)) Then
                    Me.paperSizeComboBox.SelectedItem = [TryCast](Me.paperSizeComboBox.Items.Item(0),PaperSize)
                    Me.printDocument.DefaultPageSettings.PaperSize = [TryCast](Me.paperSizeComboBox.SelectedItem,PaperSize)
                End If
            End If
            Me.paperSourceComboBox.Items.Clear
            Me.paperSourceComboBox.DisplayMember = "SourceName"
            Dim source As PaperSource
            For Each source In paperSources
                Me.paperSourceComboBox.Items.Add(source)
                If (((Me.paperSourceComboBox.SelectedItem Is Nothing) AndAlso (Me.printDocument.DefaultPageSettings.PaperSource.Kind = source.Kind)) AndAlso (Me.printDocument.DefaultPageSettings.PaperSource.SourceName = source.SourceName)) Then
                    Me.paperSourceComboBox.SelectedItem = source
                End If
            Next
            If ((Me.paperSourceComboBox.SelectedItem Is Nothing) AndAlso (Me.paperSourceComboBox.Items.Count > 0)) Then
                Me.paperSourceComboBox.SelectedItem = [TryCast](Me.paperSourceComboBox.Items.Item(0),PaperSource)
                Me.printDocument.DefaultPageSettings.PaperSource = [TryCast](Me.paperSourceComboBox.SelectedItem,PaperSource)
            End If
        End Sub

        Private Sub landscapeRadioButton_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
            Me.UpdateHeaderFooterMarginLimit
        End Sub

        Private Sub Margins_Validating(ByVal sender As Object, ByVal e As CancelEventArgs)
            Dim size As Size
            Dim marginsFromUI As Margins = Me.GetMarginsFromUI
            Dim selectedItem As PaperSize = [TryCast](Me.paperSizeComboBox.SelectedItem,PaperSize)
            If (Not selectedItem Is Nothing) Then
                size = New Size(selectedItem.Width, selectedItem.Height)
            Else
                size = Me.printDocument.DefaultPageSettings.Bounds.Size
            End If
            Dim num As Integer = (marginsFromUI.Left + marginsFromUI.Right)
            Dim num2 As Integer = (marginsFromUI.Top + marginsFromUI.Bottom)
            If ((num >= size.Width) OrElse (num2 >= size.Height)) Then
                Dim message As String = DR.GetString("EnteredMarginsAreNotValidErrorMessage", New Object(0  - 1) {})
                DesignerHelpers.ShowError(Me.serviceProvider, message)
                e.Cancel = True
            End If
        End Sub

        Private Sub OKButton_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim marginsFromUI As Margins = Me.GetMarginsFromUI
            Me.printDocument.PageSetupData.AdjustToScaleFactor = Me.adjustToRadioButton.Checked
            Me.printDocument.PageSetupData.ScaleFactor = CInt(Me.adjustToScaleInput.Value)
            Me.printDocument.PageSetupData.PagesWide = CInt(Me.fitToPagesWideInput.Value)
            Me.printDocument.PageSetupData.PagesTall = CInt(Me.fitToPagesTallInput.Value)
            Me.printDocument.PageSetupData.Landscape = Me.landscapeRadioButton.Checked
            Me.printDocument.PageSetupData.Margins = marginsFromUI
            Me.printDocument.PageSetupData.CenterHorizontally = Me.CenterHorizontallyCheckBox.Checked
            Me.printDocument.PageSetupData.CenterVertically = Me.CenterVerticallyCheckBox.Checked
            If (Me.headerTextComboBox.SelectedIndex = 0) Then
                Me.printDocument.PageSetupData.HeaderTemplate = String.Empty
            ElseIf Not Me.headerTextComboBox.Text.Equals(Me.headerFooterCustom) Then
                Me.printDocument.PageSetupData.HeaderTemplate = Me.headerTextComboBox.Text
            Else
                Me.printDocument.PageSetupData.HeaderTemplate = Me.customHeaderText.Text
            End If
            Me.printDocument.PageSetupData.HeaderCustom = Me.headerCustom
            Me.printDocument.PageSetupData.HeaderAlignment = DirectCast(Me.headerAlignmentComboBox.SelectedItem, HorizontalAlignment)
            Me.printDocument.PageSetupData.HeaderMargin = Me.UIUnitToPrinterUnit(Me.headerMarginInput.Value)
            If (Me.footerTextComboBox.SelectedIndex = 0) Then
                Me.printDocument.PageSetupData.FooterTemplate = String.Empty
            ElseIf Not Me.footerTextComboBox.Text.Equals(Me.headerFooterCustom) Then
                Me.printDocument.PageSetupData.FooterTemplate = Me.footerTextComboBox.Text
            Else
                Me.printDocument.PageSetupData.FooterTemplate = Me.customFooterText.Text
            End If
            Me.printDocument.PageSetupData.FooterCustom = Me.footerCustom
            Me.printDocument.PageSetupData.FooterAlignment = DirectCast(Me.footerAlignmentComboBox.SelectedItem, HorizontalAlignment)
            Me.printDocument.PageSetupData.FooterMargin = Me.UIUnitToPrinterUnit(Me.footerMarginInput.Value)
            If (PrinterSettings.InstalledPrinters.Count > 0) Then
                If (Not Me.paperSizeComboBox.SelectedItem Is Nothing) Then
                    Me.printDocument.DefaultPageSettings.PaperSize = DirectCast(Me.paperSizeComboBox.SelectedItem, PaperSize)
                End If
                If (Not Me.paperSourceComboBox.SelectedItem Is Nothing) Then
                    Me.printDocument.DefaultPageSettings.PaperSource = DirectCast(Me.paperSourceComboBox.SelectedItem, PaperSource)
                End If
                Me.printDocument.DefaultPageSettings.Landscape = Me.printDocument.PageSetupData.Landscape
                Me.printDocument.DefaultPageSettings.Margins = marginsFromUI
                Me.printDocument.PrinterSettings.DefaultPageSettings.PaperSize = Me.printDocument.DefaultPageSettings.PaperSize
                Me.printDocument.PrinterSettings.DefaultPageSettings.PaperSource = Me.printDocument.DefaultPageSettings.PaperSource
                Me.printDocument.PrinterSettings.DefaultPageSettings.Landscape = Me.printDocument.PageSetupData.Landscape
                Me.printDocument.PrinterSettings.DefaultPageSettings.Margins = marginsFromUI
            End If
            Me.printDocument.PageSetupData.StorePropertiesToRegistry
            MyBase.DialogResult = DialogResult.OK
        End Sub

        Protected Overrides Sub OnHelpRequested(ByVal hlpevent As HelpEventArgs)
            hlpevent.Handled = True
            Me.GetHelp
        End Sub

        Private Sub paperSizeComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
            Me.UpdateHeaderFooterMarginLimit
        End Sub

        Private Sub portraitRadioButton_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
            Me.UpdateHeaderFooterMarginLimit
        End Sub

        Private Sub printerButton_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim dialog As New PrintDialog { _
                .AllowPrintToFile = False, _
                .Document = Me.printDocument _
            }
            Try 
                If (DialogResult.OK = dialog.ShowDialog) Then
                    Me.printDocument.PrinterSettings = dialog.PrinterSettings
                    Me.printDocument.DefaultPageSettings = dialog.Document.DefaultPageSettings
                    If Me.printDocument.DefaultPageSettings.Landscape Then
                        Me.landscapeRadioButton.Checked = True
                    Else
                        Me.portraitRadioButton.Checked = True
                    End If
                    Me.InitializePaperInformation
                    Me.printDocument.Print
                End If
            Catch exception As Exception
                Dim message As String = (DR.GetString("SelectedPrinterIsInvalidErrorMessage", New Object(0  - 1) {}) & ChrW(10) & exception.Message)
                DesignerHelpers.ShowError(Me.serviceProvider, message)
            End Try
        End Sub

        Private Function PrinterUnitToUIUnit(ByVal printerValue As Integer) As Decimal
            Return Convert.ToDecimal(CDbl((CDbl(printerValue) / 100)))
        End Function

        Private Sub SetMarginsToUI(ByVal margins As Margins)
            Me.marginsLeftInput.Value = Me.PrinterUnitToUIUnit(margins.Left)
            Me.marginsRightInput.Value = Me.PrinterUnitToUIUnit(margins.Right)
            Me.marginsTopInput.Value = Me.PrinterUnitToUIUnit(margins.Top)
            Me.marginsBottomInput.Value = Me.PrinterUnitToUIUnit(margins.Bottom)
        End Sub

        Private Function UIUnitToPrinterUnit(ByVal uiValue As Decimal) As Integer
            Return Convert.ToInt32(CDbl((CDbl(uiValue) * 100)))
        End Function

        Private Sub UpdateHeaderFooterMarginLimit()
            Dim selectedItem As PaperSize = [TryCast](Me.paperSizeComboBox.SelectedItem,PaperSize)
            If (Not selectedItem Is Nothing) Then
                Me.footerMarginInput.Maximum = Me.headerMarginInput.Maximum = Me.PrinterUnitToUIUnit(If(Me.landscapeRadioButton.Checked, selectedItem.Width, selectedItem.Height))
            End If
        End Sub

        Private Sub WorkflowPageSetupDialog_HelpButtonClicked(ByVal sender As Object, ByVal e As CancelEventArgs)
            e.Cancel = True
            Me.GetHelp
        End Sub


        ' Fields
        Private adjustToRadioButton As RadioButton
        Private adjustToScaleInput As NumericUpDown
        Private cancelButton As Button
        Private centerGroup As GroupBox
        Private CenterHorizontallyCheckBox As CheckBox
        Private centerTableLayoutPanel As TableLayoutPanel
        Private CenterVerticallyCheckBox As CheckBox
        Private components As Container
        Private customFooterLabel As Label
        Private customFooterText As TextBox
        Private customHeaderLabel As Label
        Private customHeaderText As TextBox
        Private fitToPagesTallInput As NumericUpDown
        Private fitToPagesWideInput As NumericUpDown
        Private fitToRadioButton As RadioButton
        Private fitToTallLabel As Label
        Private fitToWideLabel As Label
        Private footerAlignmentComboBox As ComboBox
        Private footerAlignmentLabel As Label
        Private footerCustom As Boolean
        Private footerGroup As GroupBox
        Private footerMarginInput As NumericUpDown
        Private footerMarginLabel As Label
        Private footerMarginUnitsLabel As Label
        Private footerTableLayoutPanel As TableLayoutPanel
        Private footerTextComboBox As ComboBox
        Private footerTextLabel As Label
        Private headerAlignmentComboBox As ComboBox
        Private headerAlignmentLabel As Label
        Private headerCustom As Boolean
        Private headerFooterCustom As String
        Private headerFooterNone As String
        Private headerFooterTab As TabPage
        Private headerFooterTemplates As String()
        Private headerGroup As GroupBox
        Private headerMarginInput As NumericUpDown
        Private headerMarginLabel As Label
        Private headerMarginUnitsLabel As Label
        Private headerTableLayoutPanel As TableLayoutPanel
        Private headerTextComboBox As ComboBox
        Private headerTextLabel As Label
        Private landscapePicture As PictureBox
        Private landscapeRadioButton As RadioButton
        Private marginsBottomInput As NumericUpDown
        Private marginsBottomLabel As Label
        Private marginsGroup As GroupBox
        Private marginsLeftInput As NumericUpDown
        Private marginsLeftLabel As Label
        Private marginsRightInput As NumericUpDown
        Private marginsRightLabel As Label
        Private marginsTableLayoutPanel As TableLayoutPanel
        Private marginsTopInput As NumericUpDown
        Private marginsTopLabel As Label
        Private OKButton As Button
        Private okCancelTableLayoutPanel As TableLayoutPanel
        Private orientationGroup As GroupBox
        Private orientationTableLayoutPanel As TableLayoutPanel
        Private pageSettingsTab As TabPage
        Private paperSettingsGroup As GroupBox
        Private paperSizeComboBox As ComboBox
        Private paperSizeLabel As Label
        Private paperSourceComboBox As ComboBox
        Private paperSourceLabel As Label
        Private paperTableLayoutPanel As TableLayoutPanel
        Private portraitPicture As PictureBox
        Private portraitRadioButton As RadioButton
        Private printDocument As WorkflowPrintDocument
        Private printerButton As Button
        Private scalingGroup As GroupBox
        Private scalingOfSizeLabel As Label
        Private scalingTableLayoutPanel As TableLayoutPanel
        Private serviceProvider As IServiceProvider
        Private tabs As TabControl
    End Class
End Namespace

